/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package fy.form.groovy;

import com.seeyon.ctp.common.AppContext;
import com.seeyon.ctp.services.ServiceResponse;
import com.seeyon.ctp.services.UserToken;
import com.seeyon.v3x.services.AuthorityService;
import com.seeyon.v3x.services.flow.FlowService;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

/**
 *
 * @author Administrator 用户获取流程定义
 */
public class FormSender06 {

    private static final Log logger = LogFactory.getLog(FormSender06.class);

    public static String getFlow(Object object) {
        String data = "<formExport version=\"2.0\">\n" +
"    <summary id=\"-1\" name=\"formmain_3981\"/>\n" +
"    <definitions>\n" +
"        <column id=\"field0001\" type=\"0\" name=\"人员选择器\" length=\"255\"/>\n" +
"        <column id=\"field0002\" type=\"0\" name=\"部门选择器\" length=\"255\"/>\n" +
"        <column id=\"field0003\" type=\"0\" name=\"单位选择器\" length=\"255\"/>\n" +
"        <column id=\"field0004\" type=\"0\" name=\"子公司\" length=\"255\"/>\n" +
"        <column id=\"field0005\" type=\"3\" name=\"日期\" length=\"255\"/>\n" +
"        <column id=\"field0006\" type=\"0\" name=\"单据编号\" length=\"255\"/>\n" +
"        <column id=\"field0007\" type=\"0\" name=\"出门业务种类\" length=\"255\"/>\n" +
"        <column id=\"field0008\" type=\"0\" name=\"出门业务种类其他\" length=\"255\"/>\n" +
"        <column id=\"field0009\" type=\"0\" name=\"联系电话\" length=\"255\"/>\n" +
"        <column id=\"field0010\" type=\"0\" name=\"出厂门\" length=\"255\"/>\n" +
"        <column id=\"field0011\" type=\"0\" name=\"车号\" length=\"255\"/>\n" +
"        <column id=\"field0012\" type=\"0\" name=\"出厂原因\" length=\"255\"/>\n" +
"        <column id=\"field0013\" type=\"0\" name=\"特证单位\" length=\"255\"/>\n" +
"        <column id=\"field0014\" type=\"0\" name=\"票证号\" length=\"255\"/>\n" +
"        <column id=\"field0015\" type=\"4\" name=\"已返还次数\" length=\"20\"/>\n" +
"        <column id=\"field0016\" type=\"4\" name=\"本次返还次数\" length=\"20\"/>\n" +
"        <column id=\"field0017\" type=\"4\" name=\"是否存在未返厂物资\" length=\"20\"/>\n" +
"        <column id=\"field0044\" type=\"0\" name=\"返还关联表单\" length=\"255\"/>\n" +
"        <column id=\"field0045\" type=\"4\" name=\"状态_抓取存在未返厂物资数据\" length=\"20\"/>\n" +
"        <column id=\"field0046\" type=\"0\" name=\"单据编号1\" length=\"255\"/>\n" +
"    </definitions>\n" +
"    <values>\n" +
"        <column name=\"人员选择器\">\n" +
"            <value><![CDATA[-1825607432309486470]]></value>\n" +
"        </column>\n" +
"        <column name=\"部门选择器\">\n" +
"            <value><![CDATA[284940959660329272]]></value>\n" +
"        </column>\n" +
"        <column name=\"单位选择器\">\n" +
"            <value><![CDATA[5686590792835548528]]></value>\n" +
"        </column>\n" +
"        <column name=\"子公司\">\n" +
"            <value><![CDATA[集团总办]]></value>\n" +
"        </column>\n" +
"        <column name=\"日期\">\n" +
"            <value><![CDATA[2015-12-16]]></value>\n" +
"        </column>\n" +
"        <column name=\"单据编号\">\n" +
"            <value><![CDATA[20151200040]]></value>\n" +
"        </column>\n" +
"        <column name=\"出门业务种类\">\n" +
"            <value><![CDATA[1]]></value>\n" +
"        </column>\n" +
"        <column name=\"出门业务种类其他\">\n" +
"            <value/>\n" +
"        </column>\n" +
"        <column name=\"联系电话\">\n" +
"            <value><![CDATA[1]]></value>\n" +
"        </column>\n" +
"        <column name=\"出厂门\">\n" +
"            <value><![CDATA[0]]></value>\n" +
"        </column>\n" +
"        <column name=\"车号\">\n" +
"            <value><![CDATA[1]]></value>\n" +
"        </column>\n" +
"        <column name=\"出厂原因\">\n" +
"            <value><![CDATA[1]]></value>\n" +
"        </column>\n" +
"        <column name=\"特证单位\">\n" +
"            <value><![CDATA[1]]></value>\n" +
"        </column>\n" +
"        <column name=\"票证号\">\n" +
"            <value><![CDATA[1]]></value>\n" +
"        </column>\n" +
"        <column name=\"已返还次数\">\n" +
"            <value><![CDATA[1]]></value>\n" +
"        </column>\n" +
"        <column name=\"本次返还次数\">\n" +
"            <value><![CDATA[2]]></value>\n" +
"        </column>\n" +
"        <column name=\"是否存在未返厂物资\">\n" +
"            <value><![CDATA[131]]></value>\n" +
"        </column>\n" +
"        <column name=\"返还关联表单\">\n" +
"            <value><![CDATA[20151200040]]></value>\n" +
"        </column>\n" +
"        <column name=\"状态_抓取存在未返厂物资数据\">\n" +
"            <value><![CDATA[1]]></value>\n" +
"        </column>\n" +
"        <column name=\"单据编号1\">\n" +
"            <value/>\n" +
"        </column>\n" +
"    </values>\n" +
"    <subForms>\n" +
"        <subForm>\n" +
"            <definitions>\n" +
"                <column id=\"field0018\" type=\"0\" name=\"返还_物资明细\" length=\"255\"/>\n" +
"                <column id=\"field0019\" type=\"0\" name=\"返还_经手人\" length=\"255\"/>\n" +
"                <column id=\"field0020\" type=\"2\" name=\"返还_返回时间\" length=\"255\"/>\n" +
"                <column id=\"field0022\" type=\"0\" name=\"返还_计量单位\" length=\"255\"/>\n" +
"                <column id=\"field0023\" type=\"4\" name=\"返还_序号\" length=\"20\"/>\n" +
"                <column id=\"field0024\" type=\"4\" name=\"返还_出厂数量\" length=\"20\"/>\n" +
"                <column id=\"field0025\" type=\"4\" name=\"返还_已返还数量\" length=\"20\"/>\n" +
"                <column id=\"field0026\" type=\"4\" name=\"返还_是否需返厂\" length=\"20\"/>\n" +
"                <column id=\"field0042\" type=\"0\" name=\"返还_物资编号\" length=\"255\"/>\n" +
"                <column id=\"field0021\" type=\"4\" name=\"返还_本次返回数量\" length=\"20\"/>\n" +
"                <column id=\"field0043\" type=\"4\" name=\"返还_剩余未返回数量\" length=\"20\"/>\n" +
"                <column id=\"field0018\" type=\"0\" name=\"返还_物资明细\" length=\"255\"/>\n" +
"                <column id=\"field0019\" type=\"0\" name=\"返还_经手人\" length=\"255\"/>\n" +
"                <column id=\"field0020\" type=\"2\" name=\"返还_返回时间\" length=\"255\"/>\n" +
"                <column id=\"field0022\" type=\"0\" name=\"返还_计量单位\" length=\"255\"/>\n" +
"                <column id=\"field0023\" type=\"4\" name=\"返还_序号\" length=\"20\"/>\n" +
"                <column id=\"field0024\" type=\"4\" name=\"返还_出厂数量\" length=\"20\"/>\n" +
"                <column id=\"field0025\" type=\"4\" name=\"返还_已返还数量\" length=\"20\"/>\n" +
"                <column id=\"field0026\" type=\"4\" name=\"返还_是否需返厂\" length=\"20\"/>\n" +
"                <column id=\"field0042\" type=\"0\" name=\"返还_物资编号\" length=\"255\"/>\n" +
"                <column id=\"field0021\" type=\"4\" name=\"返还_本次返回数量\" length=\"20\"/>\n" +
"                <column id=\"field0043\" type=\"4\" name=\"返还_剩余未返回数量\" length=\"20\"/>\n" +
"            </definitions>\n" +
"            <values/>\n" +
"        </subForm>\n" +
"        <subForm>\n" +
"            <definitions>\n" +
"                <column id=\"field0027\" type=\"0\" name=\"明细_物资名称\" length=\"255\"/>\n" +
"                <column id=\"field0028\" type=\"0\" name=\"明细_计量单位\" length=\"255\"/>\n" +
"                <column id=\"field0029\" type=\"4\" name=\"明细_数量\" length=\"20\"/>\n" +
"                <column id=\"field0030\" type=\"0\" name=\"明细_备注\" length=\"255\"/>\n" +
"                <column id=\"field0031\" type=\"4\" name=\"明细_是否返还\" length=\"20\"/>\n" +
"                <column id=\"field0032\" type=\"3\" name=\"明细_预计返回时间\" length=\"255\"/>\n" +
"                <column id=\"field0033\" type=\"4\" name=\"明细_已返还总量\" length=\"20\"/>\n" +
"                <column id=\"field0034\" type=\"4\" name=\"明细_序号\" length=\"20\"/>\n" +
"                <column id=\"field0027\" type=\"0\" name=\"明细_物资名称\" length=\"255\"/>\n" +
"                <column id=\"field0028\" type=\"0\" name=\"明细_计量单位\" length=\"255\"/>\n" +
"                <column id=\"field0029\" type=\"4\" name=\"明细_数量\" length=\"20\"/>\n" +
"                <column id=\"field0030\" type=\"0\" name=\"明细_备注\" length=\"255\"/>\n" +
"                <column id=\"field0031\" type=\"4\" name=\"明细_是否返还\" length=\"20\"/>\n" +
"                <column id=\"field0032\" type=\"3\" name=\"明细_预计返回时间\" length=\"255\"/>\n" +
"                <column id=\"field0033\" type=\"4\" name=\"明细_已返还总量\" length=\"20\"/>\n" +
"                <column id=\"field0034\" type=\"4\" name=\"明细_序号\" length=\"20\"/>\n" +
"                <column id=\"field0027\" type=\"0\" name=\"明细_物资名称\" length=\"255\"/>\n" +
"                <column id=\"field0028\" type=\"0\" name=\"明细_计量单位\" length=\"255\"/>\n" +
"                <column id=\"field0029\" type=\"4\" name=\"明细_数量\" length=\"20\"/>\n" +
"                <column id=\"field0030\" type=\"0\" name=\"明细_备注\" length=\"255\"/>\n" +
"                <column id=\"field0031\" type=\"4\" name=\"明细_是否返还\" length=\"20\"/>\n" +
"                <column id=\"field0032\" type=\"3\" name=\"明细_预计返回时间\" length=\"255\"/>\n" +
"                <column id=\"field0033\" type=\"4\" name=\"明细_已返还总量\" length=\"20\"/>\n" +
"                <column id=\"field0034\" type=\"4\" name=\"明细_序号\" length=\"20\"/>\n" +
"                <column id=\"field0027\" type=\"0\" name=\"明细_物资名称\" length=\"255\"/>\n" +
"                <column id=\"field0028\" type=\"0\" name=\"明细_计量单位\" length=\"255\"/>\n" +
"                <column id=\"field0029\" type=\"4\" name=\"明细_数量\" length=\"20\"/>\n" +
"                <column id=\"field0030\" type=\"0\" name=\"明细_备注\" length=\"255\"/>\n" +
"                <column id=\"field0031\" type=\"4\" name=\"明细_是否返还\" length=\"20\"/>\n" +
"                <column id=\"field0032\" type=\"3\" name=\"明细_预计返回时间\" length=\"255\"/>\n" +
"                <column id=\"field0033\" type=\"4\" name=\"明细_已返还总量\" length=\"20\"/>\n" +
"                <column id=\"field0034\" type=\"4\" name=\"明细_序号\" length=\"20\"/>\n" +
"            </definitions>\n" +
"            <values/>\n" +
"        </subForm>\n" +
"        <subForm>\n" +
"            <definitions>\n" +
"                <column id=\"field0035\" type=\"0\" name=\"记录_物资名称\" length=\"255\"/>\n" +
"                <column id=\"field0036\" type=\"0\" name=\"记录_计量单位\" length=\"255\"/>\n" +
"                <column id=\"field0037\" type=\"0\" name=\"记录_经手人\" length=\"255\"/>\n" +
"                <column id=\"field0038\" type=\"2\" name=\"记录_返还时间\" length=\"255\"/>\n" +
"                <column id=\"field0039\" type=\"4\" name=\"记录_返回数量\" length=\"20\"/>\n" +
"                <column id=\"field0040\" type=\"4\" name=\"记录_次数\" length=\"20\"/>\n" +
"                <column id=\"field0041\" type=\"4\" name=\"记录_序号\" length=\"20\"/>\n" +
"                <column id=\"field0035\" type=\"0\" name=\"记录_物资名称\" length=\"255\"/>\n" +
"                <column id=\"field0036\" type=\"0\" name=\"记录_计量单位\" length=\"255\"/>\n" +
"                <column id=\"field0037\" type=\"0\" name=\"记录_经手人\" length=\"255\"/>\n" +
"                <column id=\"field0038\" type=\"2\" name=\"记录_返还时间\" length=\"255\"/>\n" +
"                <column id=\"field0039\" type=\"4\" name=\"记录_返回数量\" length=\"20\"/>\n" +
"                <column id=\"field0040\" type=\"4\" name=\"记录_次数\" length=\"20\"/>\n" +
"                <column id=\"field0041\" type=\"4\" name=\"记录_序号\" length=\"20\"/>\n" +
"            </definitions>\n" +
"            <values/>\n" +
"        </subForm>\n" +
"    </subForms>\n" +
"</formExport>\n" +
"";

        String result = "";
        try {
            AuthorityService as = (AuthorityService) AppContext.getBean("authorityService");

            UserToken token = as.authenticate("service-admin", "123456");
            logger.info("result:" + token);
            logger.info("result:" + token.getId());

            FlowService fs = (FlowService) AppContext.getBean("BPMService");

//            fs.getTemplateDefinition(result, result);
            ServiceResponse r = fs.launchFormCollaboration(token.getId(), "002218", "o_r_01", "测试", data, null, "1", null);

            logger.info("result:" + r.getErrorMessage());
            logger.info("result:" + r.toString());

        } catch (Exception ex) {
            ex.printStackTrace();
            logger.error(ex);
        }
        return result;
    }
}
